<?php
namespace datos;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LoginDao
 *
 * @author Jorge
 */
class LoginDao {
    //put your code here
    private $conexion;
    
    public function __construct($conexion) {
        $this->conexion = $conexion;
    }
    
    public function login($username, $password){
        $sql = "SELECT 
               v.cod_vendedor,
               v.nombre,
               v.rut,
               v.telefono,
               v.direccion,               
               v.perfil, 
               v.estado       
               FROM vendedor v
               WHERE v.cod_vendedor = '$username'
               AND v.contrasena = '$password'
               AND v.estado != 'b'";
        $consulta = mysql_query($sql,$this->conexion)or die("Error en la consulta" . mysql_error()); 
        $nfilas = mysql_num_rows($consulta);
        if($nfilas > 0){
            return mysql_fetch_array($consulta);
        }else{
            return null;
        }
    }
    
    public function obtenerDatosEmpresa(){
        $sql = "SELECT 
                id, 
                razon_social, 
                giro, 
                rut, 
                direccion, 
                numero_direccion, 
                comuna, 
                ciudad, 
                fono, 
                fax, 
                email, 
                web
                FROM datos_empresa;";
        $consulta = mysql_query($sql,$this->conexion)or die("Error en la consulta" . mysql_error()); 
        $nfilas = mysql_num_rows($consulta);
        if($nfilas > 0){
            return mysql_fetch_array($consulta);
        }else{
            return null;
        }
    }
            
            
    
}
